package com.awei.study.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author liweilong
 * @Date 2024/11/2 3:13
 */
public class CreateThreadF {

    private static int a = 1;
    static class MyThread implements Callable<String> {

        @Override
        public String call() throws Exception {
            a++;
            System.out.println("执行完成");
            return "ok";
        }
    }

    static class MyThread1 extends Thread {
        @Override
        public void run() {
            a++;
        }
    }
    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        MyThread myThread = new MyThread();
//        FutureTask<String> task = new FutureTask<>(myThread);
//        Thread thread = new Thread(task);
//        thread.start();
//        System.out.println(task.get());
        for (int i = 0; i < 10000; i++) {
            new MyThread1().start();
        }
        System.out.println(a);
    }
}
